home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 3 / ct-rom iiib.zip / ct-rom iiib / OS2 / PROGRAM / LB05 / README.TXT < prev    next >
Text File  |  1994-03-19  |  11KB  |  296 lines

  1. Liberty BASIC for OS/2 Notes
  2. --------------------------------------------------------------------------------------
  3.  
  4.  
  5. Design of the Language:
  6.  
  7. Liberty BASIC is designed to feel familiar to Microsoft BASIC programmers.
  8. By this I mean the versions of BASIC named MBASIC and GWBASIC.  I wanted 
  9. to create a tool that made long time BASIC programmers feel comfortable 
  10. writing Windows and OS/2 programs.  To do this I tried to add windowing 
  11. commands whose syntax that felt as much like BASIC as possible.  Liberty 
  12. BASIC programs are similar (but not necessarily compatible) to 
  13. MBASIC/GWBASIC programs.
  14.  
  15.  
  16. The Intended Market:
  17.  
  18. Liberty BASIC is marketed as shareware.  I wanted to create an inexpensive 
  19. package that would appeal to the casual BASIC programmer, as a protyping 
  20. tool,  and to school teachers.  To do this, I made my it primary goal to 
  21. produce a tool that is SIMPLE first of all.  Liberty BASIC is designed 
  22. to work well with most school textbook examples in the BASIC programming 
  23. language.
  24.  
  25. Because the software is created using Smalltalk/V (an extremely powerful 
  26. tool), it is sizeable.  If you require great speed or diminutive size, 
  27. look elsewhere.
  28.  
  29. Software developed in Liberty BASIC can be distributed royalty free if 
  30. you register to receive the runtime engine.
  31.  
  32.  
  33. Hardware requirements:
  34.  
  35. Liberty BASIC is comfortable on any machine that runs OS/2 comfortably.  
  36. In other words you need 8 or more megabytes or RAM, and at least a few 
  37. free megabytes of free disk space.  Liberty BASIC works best with a mouse.
  38. There are no other special requirements.
  39.  
  40.  
  41. Compatility / Incompatibility:
  42.  
  43. Much of MBASIC / GWBASIC is there, and when something isn't there I will
  44. strive to add it, but the graphics stuff is completely different.
  45.  
  46.   Some of what's there:
  47.  
  48.     FOR . . . NEXT
  49.     WHILE . . . WEND
  50.     FIELD, GET, PUT (slightly modified though, and better)
  51.     IF . . . THEN . . . ELSE . . .
  52.  
  53.   Some of what's not there:
  54.  
  55.     ON . . . GOTO . . .
  56.     READ, DATA
  57.     ON ERROR . . .
  58.     LOCATE
  59.  
  60.   In the works . . .
  61.  
  62.     Communications support
  63.     DEFFN( )   - multi-line functions with local vars
  64.  
  65.  
  66. The PRINT and INPUT statements are there, and simple text-mode programs
  67. can be written, but take a look at the included DRAW.BAS and CONTACT.BAS
  68. programs for some handily written GUI programs.
  69.  
  70. Some have asked me for PEEK and POKE.  I have not included them because 
  71. OS/2 and PM take care of the low level stuff, and those statements are 
  72. really not appropriate (or safe) in a virtualized GUI environment.  
  73. However the ability to make API calls and to access external DLLs is 
  74. definitely in the list of future improvements.
  75.  
  76.  
  77. Variables and Arrays:
  78.  
  79. Liberty BASIC has very simple variable typing.  Both variableName and
  80. variableName$ conventions are supported, but variables are actually
  81. untyped.  Explicitly defined integers and double precision variables are
  82. not supported.
  83.  
  84. Numeric types are automatically truncated to integer types if there is no
  85. fraction part for efficiency, and when a number is a float, an available
  86. math coprocessor is automatically used.  Integers can be HUGE (try the
  87. FACTORIL.BAS program)!!
  88.  
  89. Strings can be as large as available memory!
  90.  
  91. Arrays are typed.  They expect a numeric data type if there is no $ 
  92. character on the end of the array name, and they expect a string type 
  93. if there is a $ character.  Arrays can be single and double dimensioned 
  94. only (no three or four dimensional arrays, sorry), but they can be as 
  95. large as available memory!
  96.  
  97. A powerful SORT command provides a knockout easy way to sort single and 
  98. double dimensioned arrays.  When a double dimensioned array is sorted, 
  99. you pick the column, and each row of data is sorted by its information 
  100. in that column.  This gives you lightning fast, database-like sorting 
  101. cabability.
  102.  
  103.  
  104. Line Numbers:
  105.  
  106. Line numbers are optionally supported in Liberty BASIC.  You can number 
  107. program lines in the completely traditional way (ie. 10, 20, 30, etc) or 
  108. you can dispense with line numbers and use alphanumeric branch labels 
  109. instead.  Instead of GOTO 1435, your code might read GOTO [response], or 
  110. maybe GOTO [redrawGraphic].  A branch label can be any unique combination 
  111. of letters and digits inside a pair of square braces.  No spaces are 
  112. allowed.  The sample programs included use this convention.
  113.  
  114.  
  115. File handling:
  116.  
  117. File handle names can be any alphanumeric combination of letters and
  118. digits following a # character, for example here is #data as the file
  119. handle:
  120.  
  121.   OPEN "custdata.dat" for random as #data
  122.  
  123. Now anywhere in Microsoft BASIC where the file handle is used, the #
  124. character is omitted, but you must remember to use the # character when
  125. referring to file handles in Liberty BASIC.  For example, see the FIELD
  126. statement example below.
  127.  
  128. Sequential file handling is as expected.  Random access looks almost just
  129. like Microsoft's, but is easier.  Here we dispense with LSET and RSET and
  130. all those crazy functions for moving information in and out of FIELD 
  131. statement variables.
  132.  
  133. In Liberty BASIC, a FIELD statement looks like this:
  134.  
  135.   FIELD #data, 10 as orderCode$, 7 as idNumber, 20 as customer$, . . . 
  136.  
  137. Before a PUT, simply assign orderCode$ to be a string value, assign
  138. idNumber to be a numeric type, and assign customer$ to be a string type. 
  139. When PUT is performed, it will place ASCII, eye readable representations 
  140. of these values into the file at the specified record number.
  141.  
  142. Later if a GET is performed, the information is read straight back into 
  143. the variables, and numeric fields are automatically converted to numeric 
  144. type.   There aren't any conversion steps necessary.  See CONTACT.BAS for 
  145. an example.
  146.  
  147.  
  148. Windows:
  149.  
  150. Liberty BASIC treats windows like files.  You use the OPEN command to 
  151. open a window and you use the CLOSE command to close it.  To add controls 
  152. to a window, you list the controls before you open the window.  Once the 
  153. window is open, you can send commands by PRINTing to the controls, and 
  154. you can get information from the controls by INPUTing from them.
  155.  
  156. Here's a short example:
  157.  
  158.     ' CHECKBOX.BAS
  159.     ' This code demonstrates how to use checkboxes in your
  160.     ' Liberty BASIC programs
  161.  
  162.     ' no main text mode window, please
  163.     nomainwin
  164.  
  165.     ' list all the controls for our dialog box window
  166.     button #1, " &Ok ", [quit], UL, 120, 90
  167.     checkbox #1.cb, "I am a checkbox", [set], [reset], 10, 10, 130, 20
  168.     button #1, " Set ", [set], UL, 10, 50
  169.     button #1, " Reset ", [reset], UL, 50, 50
  170.     textbox #1.text, 10, 90, 100, 24
  171.  
  172.     ' set the size for our window
  173.     WindowWidth = 180
  174.     WindowHeight = 160
  175.  
  176.     ' open the window
  177.     open "Checkbox test" for dialog as #1
  178.  
  179.     ' intercept the close message and goto [quit]
  180.     print #1, "trapclose [quit]"
  181.  
  182.  
  183. [inputLoop]    ' this is where we sit idle, waiting for the user to click
  184.  
  185.     input r$ 
  186.     stop
  187.  
  188. [set]    ' the user clicked on the Set button, set the checkbox
  189.  
  190.     print #1.cb, "set"
  191.     goto [readCb]
  192.  
  193.  
  194. [reset]    ' the user clicked on the Reset button, clear the checkbox
  195.     print #1.cb, "reset"
  196.     goto [readCb]
  197.  
  198.  
  199. [readCb]    ' set the contents of the textbox
  200.  
  201.     ' query the checkbox for its state
  202.     print #1.cb, "value?"
  203.     input #1.cb, t$
  204.  
  205.     ' set the contents of our textbox
  206.     print #1.text, "I am "; t$
  207.  
  208.     goto [inputLoop]
  209.  
  210.  
  211. [quit]    ' check to see if we should quit
  212.  
  213.     confirm "Do you want to quit?"; answer$
  214.     if answer$ <> "yes" then [inputLoop]
  215.  
  216.     ' disable trapping of close message so we can close the window
  217.     print #1, "trapclose"
  218.     close #1
  219.     end
  220.  
  221.  
  222. In the above example we show just how easy it can be to program for 
  223. Presentation Manager (the Windows version works exactly the same way).  
  224. We have a small dialog box with a checkbox, a textbox (aka entryfield), 
  225. and three buttons.  The Tab key and Alt-key combinations are all effective.  
  226. All the controls are listed before we open the window, and the checkbox 
  227. and textbox are given subhandles of the window so that we can address them.
  228.  
  229. The buttons are the simplest to program.  We give them a label, a branch 
  230. label, and a position.  When the user clicks on the button, the BASIC 
  231. program branches to that label (as in GOTO) and continues execution.
  232.  
  233. The checkbox is similar, but it has two possible states.  We give it a 
  234. subhandle (in this case #1.cb) so we can PRINT to it and INPUT from it.  
  235. When we click on it, it also has a branch label to follow, like the 
  236. button above.
  237.  
  238. The textbox (aka entryfield) lets us enter information (reading it with 
  239. INPUT), and also display it (with the PRINT statement).
  240.  
  241. The trapclose command is sent to the dialog box so that when the user 
  242. tries to close the dialog, we can control how this occurs.  See how the 
  243. [quit] routine is automatically invoked, so that the user can confirm 
  244. the action.
  245.  
  246. This simple method of window control is used throughout.  No API calls 
  247. are needed to write useful Presentation Manager applications.
  248.  
  249.  
  250. The Debugger:
  251.  
  252. Liberty BASIC comes with a source level debugger, so you can watch 
  253. variables change, and single step through your code.  To use it, pick 
  254. the Debug option instead of Run on the Source pull-down menu.
  255.  
  256. The Trace Window appears with two text panes.  The pane on the top shows 
  257. each variable change values.  The pane below shows your program's code, 
  258. and highlights each line as it executes.
  259.  
  260. Three modes are available, and there is a button for each at the bottom 
  261. of the Trace Window.  The Step mode executes one line at a time, 
  262. highlighting as it goes, the Walk mode runs the program continuously, 
  263. highlighting each line, and the Run mode runs without tracing.
  264.  
  265. You must close the Trace Window yourself when done with it.
  266.  
  267.  
  268. Runtime Distribution:
  269.  
  270. When I begin asking for registrations, I will begin shipping a runtime 
  271. engine (which already exists) as an incentive to register.  This runtime 
  272. engine will run tokenized programs, and will be largely compatible with 
  273. the Windows version of Liberty BASIC and its runtime engine.  This will 
  274. allow development of a single source and tokenized file that will run on 
  275. either platform with little or no modification.  It will not be 
  276. necessary to ship the source code with the program.
  277.  
  278. The runtime engine features a compile-on-demand technique that only 
  279. compiles BASIC statements as it needs them, and once any statement has 
  280. been compiled, it will run again without needing to be recompiled.  
  281. This allows even large Liberty BASIC programs to 'start right up', 
  282. avoiding long compile times for runtime apps.
  283.  
  284. ----------------------------------------------------------------
  285.  
  286. Contact Information:
  287.  
  288. For more information, contact me at the address, phone # or CIS # below:
  289.  
  290. Shoptalk Systems
  291. Carl Gundel
  292. P.O. Box 1062
  293. Framingham, MA  01701
  294. (508) 872-5315
  295. CIS 71231,1532
  296.